<?
/*****************************************************************************
 * 文件名：AddNewWord.php
 * 作用：AddNewWord控制器类 负责添加新词汇
 * 创建时间：2010.1.25
 * 作者：赵鹏城
 * ****************************************************************************/
?>

<?php

class Controller_AddNewWord extends FLEA_Controller_Action
{
    /*数据表对象*/
    var $word_type_tdg;
    var $word_bank_tdg;

    /*构造函数*/
    function Controller_AddNewWord() {
        $this->word_type_tdg = & FLEA::getSingleton('Model_WordType');
        $this->word_bank_tdg = & FLEA::getSingleton('Model_WordBank');
    }
    
    /*
     * 默认action
     */
    function actionIndex() {
        $rowset = $this->word_type_tdg->findAll();
        include("AddNewWord.php");
    }
    
    function actionManualAdd() {
        //dump($_POST);
        if (empty($_POST)) {
            die("sys error!");
        }
        if (empty($_POST['word']) || empty($_POST['score'])) {
            echo "<a href=".url('AddNewWord')." target=\"_self\" class=\"Dig\"><strong>返回</strong></a>";
            die("信息不全，请完善信息！");
        }
        $score = floatval($_POST['score']);
        if (empty($score)) {
            echo "<a href=".url('AddNewWord')." target=\"_self\" class=\"Dig\"><strong>返回</strong></a>";
            die("分数类型不正确，请使用小数");
        }
        $new_row = array(
            'word' => $_POST['word'],
            'type' => $_POST['type'],
            'gender' => $_POST['gender'],
            'score' => $score,
            'isgood' => 1,
        );
        //dump($new_row);
        $this->word_bank_tdg->create($new_row);
        include("ManualAddAfter.php");
    }
    
    function actionViewGender() {
        include("GenderSpecify.php");
    }

}

?>
